module Api
  module V1
    class AutocompleteController < ApplicationController

      def index
        words = []
        if search_string
          words = Post.autocomplete(search_string)
        end
        render json: words.to_json
      end

      private

      def search_string
        params[:q].presence
      end
    end
  end
end
